﻿using Weibo4Sharp.Model;
using Hammock.Web;
using System.IO;

namespace Weibo4Sharp.Service
{
    public partial class WeiboService
    {
        public virtual WeiboUser VerifyCredentials()
        {
            return WithHammock<WeiboUser>("account/verify_credentials", FormatAsString);
        }

        public virtual WeiboRateLimitStatus GetRateLimitStatus()
        {
            return WithHammock<WeiboRateLimitStatus>("account/rate_limit_status", FormatAsString);
        }

        public virtual WeiboUser EndSession()
        {
            return WithHammock<WeiboUser>(WebMethod.Post, "account/end_session", FormatAsString);
        }

        public virtual WeiboUser UpdateDeliveryDevice(WeiboDeliveryDevice device)
        {
            return WithHammock<WeiboUser>("account/update_delivery_device", FormatAsString, "?device=", device);
        }

        public virtual WeiboUser UpdateProfileColors(string backgroundColor, string textColor, string linkColor, string sidebarFillColor, string sidebarBorderColor)
        {
            return WithHammock<WeiboUser>(WebMethod.Post, "account/update_profile_colors", FormatAsString, "?background_color=", backgroundColor, "&text_color=", textColor, "&link_color=", linkColor, "&sidebar_fill_color=", sidebarFillColor, "&sidebar_border_color=", sidebarBorderColor);
        }

        public virtual WeiboUser UpdateProfileColors(string backgroundColor)
        {
            return WithHammock<WeiboUser>(WebMethod.Post, "account/update_profile_colors", FormatAsString, "?background_color=", backgroundColor);
        }

        public virtual WeiboUser UpdateProfileColors(string backgroundColor, string textColor)
        {
            return WithHammock<WeiboUser>(WebMethod.Post, "account/update_profile_colors", FormatAsString, "?background_color=", backgroundColor, "&text_color=", textColor);
        }

        public virtual WeiboUser UpdateProfileColors(string backgroundColor, string textColor, string linkColor)
        {
            return WithHammock<WeiboUser>(WebMethod.Post, "account/update_profile_colors", FormatAsString, "?background_color=", backgroundColor, "&text_color=", textColor, "&link_color=", linkColor);
        }

        public virtual WeiboUser UpdateProfileColors(string backgroundColor, string textColor, string linkColor, string sidebarFillColor)
        {
            return WithHammock<WeiboUser>(WebMethod.Post, "account/update_profile_colors", FormatAsString, "?background_color=", backgroundColor, "&text_color=", textColor, "&link_color=", linkColor, "&sidebar_fill_color=", sidebarFillColor);
        }

        public virtual WeiboUser UpdateProfileImage(Stream image)
        {
            var request = PrepareHammockQuery("account/update_profile_image" + FormatAsString);
            request.Method = WebMethod.Post;
            request.AddFile("image", "image", image);

            return WithHammockImpl<WeiboUser>(request);           
        }

        public virtual WeiboUser UpdateProfileBackgroundImage(string path)
        {
            return WithHammock<WeiboUser>(WebMethod.Post, "account/update_profile_background_image", FormatAsString, "?path=", path);
        }

        public virtual WeiboUser UpdateProfile(string name, string gender, int privince, int city, string description)
        {
            return WithHammock<WeiboUser>(WebMethod.Post,
                "account/update_profile", FormatAsString,
                "?name=", name,
                "&gender=", gender,
                "&privince=", privince,
                "&city=", city,
                "&description=", description);
        }       
    }
}
